package org.supda.system.util.search;

import java.sql.Timestamp;
import java.text.ParseException;
import java.util.Date;

import org.supda.system.util.DateUtil;

/**
 * DataTablePageUtil辅助日期处理类
 * @author SEELE
 *
 *{ "name": "datesearch", "value": {"datemin": $("#datemin").val(), "datemax": $("#datemax").val(), "pattern":"yyyy-MM-dd", "datatype":"startTime"}}
 */
public class DateSearch {
	//转换模式,默认处理方式为yyyy-MM-dd
	private String pattern = "yyyy-MM-dd";
	//对应字段
	private String datatype;
	public String getDatatype() {
		return datatype;
	}

	public void setDatatype(String datatype) {
		this.datatype = datatype;
	}
	//最小值
	private String datemin;
	//最大值
	private String datemax;
	
	public Timestamp getTimestampDatemax() throws ParseException{
		return DateUtil.parseToTimestamp(datemax, pattern);
	}
	
	public Date getDateDatemax() throws ParseException{
		return DateUtil.parse(datemax, pattern);
	}
	
	public Timestamp getTimestampDatemin() throws ParseException{
		return DateUtil.parseToTimestamp(datemin, pattern);
	}
	
	public Date getDateDatemin() throws ParseException{
		return DateUtil.parse(datemin, pattern);
	}
	
	public String getPattern() {
		return pattern;
	}
	public void setPattern(String pattern) {
		this.pattern = pattern;
	}
	public String getDatemin() {
		return datemin;
	}
	public void setDatemin(String datemin) {
		this.datemin = datemin;
	}
	public String getDatemax() {
		return datemax;
	}
	public void setDatemax(String datemax) {
		this.datemax = datemax;
	}
}
